Skip to content

Add Weather Station device support#460

Open
fankai777 wants to merge 3 commits intosblibs:masterfrom
fankai777:feat/weather
Open

Add Weather Station device support#460
fankai777 wants to merge 3 commits intosblibs:masterfrom
fankai777:feat/weather

Conversation

@fankai777
Copy link
Contributor

Summary

Add support for the SwitchBot Weather Station BLE device, a sensor device that broadcasts temperature, humidity, and battery level via BLE advertisements.

Changes

Features

  • Add SwitchbotModel.WEATHER_STATION enum value
  • Register Weather Station with device type bytes 0x00 0x10 0x53 0xB0 (normal) and 0x01 0x10 0x53 0xB0 (pairing)

Parser

  • Add process_weather_station advertisement parser in switchbot/adv_parsers/weather_station.py
  • Parses temperature (°C/°F), humidity (%), and battery level from manufacturer data
  • Data offsets: battery at mfr_data[7], temp/humidity at mfr_data[8:11]

Tests

  • Add active and passive advertisement parsing tests for Weather Station

fankai777 and others added 2 commits March 13, 2026 16:43
Add BLE advertisement parser and device registration for the SwitchBot
Weather Station. Parses temperature, humidity, and battery from broadcast
data. Includes unit tests for active and passive advertisement parsing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
switchbot/adv_parser.py 97.82% <100.00%> (+0.01%) ⬆️
switchbot/adv_parsers/weather_station.py 100.00% <100.00%> (ø)
switchbot/const/__init__.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Add tests for service-data-only path, zero-data guard, and short
manufacturer data. Remove unused devices/weather_station.py stub.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds SwitchBot Weather Station BLE advertisement support by introducing a dedicated parser, registering the new model in the supported-type map, and validating behavior via new advertisement parsing tests.

Changes:

  • Add SwitchbotModel.WEATHER_STATION and register Weather Station model bytes in SUPPORTED_TYPES.
  • Introduce process_weather_station advertisement parser to decode temperature/humidity/battery.
  • Add active/passive/service-data-only/empty-data test cases for Weather Station advertisements.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/test_adv_parser.py Adds Weather Station parsing test coverage for multiple advertisement shapes.
switchbot/const/__init__.py Introduces WEATHER_STATION in SwitchbotModel.
switchbot/adv_parsers/weather_station.py Implements Weather Station adv payload decoding logic.
switchbot/adv_parser.py Registers Weather Station parser + model identifiers in SUPPORTED_TYPES.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +32 to +39
if not temp_data:
temp_data = data[3:6]
if battery is None:
battery = data[2] & 0b01111111

if not temp_data:
return {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants